% make_tidegaugeLocations.m
%
% Saves a .mat file with names and positions of tide gauges of interest.
% See Z_tidegaugeLocations.m for a list of gauges and positions. Assumes
% tide gauge locations are fixed - if a tide gauge moves, but isn't renamed
% then the script Z_tidegaugeLocations.m will need to be modified to
% include a datenum time variable.
%
%
% CALLS:
%   tidegauge_name2id.m
%   Z_tidegaugeLocations.m
% 
%
% OUTPUT:
%   tidegaugeLocations.mat
%
%   containing a structure 'tgauge' with fields
%     tgauge.station_name  -  the name of the tide gauge
%     tgauge.station_id    -  the station ID of the tide gauge
%     tgauge.lon           -  longitude [degrees], -180 to 180 format
%     tgauge.lat           -  latitude [degrees]
%
%
% R. McCabe 04/2014


%% User switches
savematfile = 0; % 1 = save a .mat file, 0 = do not save


%% Get tide gauge locations of interest from Z_tidegaugeLocations.m
% Specify the locations of interest - the present list is for the Cascadia
% model grid from 43N-50N inluding the Salish Sea...
mlocations = {'Campbell River','Point Atkinson','Vancouver','Cherry Point',...
    'Patricia Bay','Friday Harbor','Victoria','Port Angeles','Port Townsend',...
    'Seattle','Tacoma','Tofino','Bamfield','Neah Bay','La Push','Westport',...
    'Toke Point','Astoria','Garibaldi','South Beach','Charleston'};

% Loop through locations and pack name, lon, lat into structure 'tgauge'
for mnum = 1:length(mlocations)
    mloc = mlocations{mnum};
    tgauge(mnum).station_name = mloc;
    
    % Get official station ID for the current tide gauge
    [tg_id] = tidegauge_name2id(mloc);
    tgauge(mnum).station_id = tg_id;
    
    % Get lat,lon for the current tide gauge
    [lon,lat] = Z_tidegaugeLocations(mloc);
    tgauge(mnum).lon = lon;
    tgauge(mnum).lat = lat;
    clear mloc tg_id lon lat
end
clear mnum


%% Save a .mat file
if savematfile
    save('tidegaugeLocations.mat','tgauge');
end


